package game.leon.engine.net.example.client;

import game.leon.engine.net.GateClient;
import game.leon.engine.net.codec.GateRawMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * User: bianpeng
 * Date: 11-12-27
 */
@Component
public class Client {
    @Value("#{app.game_host}")
    private String host;
    @Value("#{app.game_port}")
    private int port;
    GateClient client = new GateClient();
    @Autowired
    private ClientMessageHandler clientMessageHandler;
    public void start() throws IOException {
        client.connect(host, port, clientMessageHandler);
    }
    public void send(GateRawMessage message) {
        client.send(message);
    }
}
